// 用户模块
const state = {
  userInfo: {},
  memInfo: {},
  token: '',
  privateKey: '',
  saveAddressInfo: {
    contactName: '',
  },
  savedTime: '',
  // 是否展示首页弹窗
  showPopPicNew: false,
  // 服务提供商
  provider: 'weixin',
  appname: '',
  //  是否要调用定位
  locRequest: true,


  isShowToast:false, // 是否在展示Toast中
  remark:[], //填写订单备注
  shareLink:"", //分享链接
  verificationKey: "", //获取key表示验证通过
  distributionId:"", //分销员Id 如果当前账户从未登录过时记录
};

const mutations = {
  SET_BASE_INFO: (state, payload) => {
    Object.keys(payload).forEach(key => {
      state[key] = payload[key];
    });
  },



  login(state, userInfo) {
    state.userInfo = userInfo || {};
    state.userName =
        userInfo.Name || userInfo.Nickname || userInfo.Username || "匿名用户";
    state.hasLogin = true;
  },
  logout(state) {
    state.userName = "";
    state.hasLogin = false;
  },

  // 设置填写订单中备注
  setRemark(state, remark) {
    state.remark = remark;
  }
};

const actions = {
  setBaseInfo({ commit }, data) {
    commit('SET_BASE_INFO', data);
  },
  setRemark({ commit }, data) {
    commit('setRemark', data);
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
